/**
 */
package Alloy.provider;

import Alloy.util.AlloyAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class AlloyItemProviderAdapterFactory extends AlloyAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AlloyItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Specification} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SpecificationItemProvider specificationItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Specification}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSpecificationAdapter() {
		if (specificationItemProvider == null) {
			specificationItemProvider = new SpecificationItemProvider(this);
		}

		return specificationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Universal} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UniversalItemProvider universalItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Universal}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUniversalAdapter() {
		if (universalItemProvider == null) {
			universalItemProvider = new UniversalItemProvider(this);
		}

		return universalItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Ruleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RulesetItemProvider rulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Ruleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRulesetAdapter() {
		if (rulesetItemProvider == null) {
			rulesetItemProvider = new RulesetItemProvider(this);
		}

		return rulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.KindRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected KindRulesetItemProvider kindRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.KindRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createKindRulesetAdapter() {
		if (kindRulesetItemProvider == null) {
			kindRulesetItemProvider = new KindRulesetItemProvider(this);
		}

		return kindRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.SubKindRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SubKindRulesetItemProvider subKindRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.SubKindRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSubKindRulesetAdapter() {
		if (subKindRulesetItemProvider == null) {
			subKindRulesetItemProvider = new SubKindRulesetItemProvider(this);
		}

		return subKindRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.RelatorRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelatorRulesetItemProvider relatorRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.RelatorRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRelatorRulesetAdapter() {
		if (relatorRulesetItemProvider == null) {
			relatorRulesetItemProvider = new RelatorRulesetItemProvider(this);
		}

		return relatorRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.PhasePartitionRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PhasePartitionRulesetItemProvider phasePartitionRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.PhasePartitionRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPhasePartitionRulesetAdapter() {
		if (phasePartitionRulesetItemProvider == null) {
			phasePartitionRulesetItemProvider = new PhasePartitionRulesetItemProvider(this);
		}

		return phasePartitionRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.ModeRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModeRulesetItemProvider modeRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.ModeRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createModeRulesetAdapter() {
		if (modeRulesetItemProvider == null) {
			modeRulesetItemProvider = new ModeRulesetItemProvider(this);
		}

		return modeRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.QualityRuleset} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityRulesetItemProvider qualityRulesetItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.QualityRuleset}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createQualityRulesetAdapter() {
		if (qualityRulesetItemProvider == null) {
			qualityRulesetItemProvider = new QualityRulesetItemProvider(this);
		}

		return qualityRulesetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Rule} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RuleItemProvider ruleItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Rule}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRuleAdapter() {
		if (ruleItemProvider == null) {
			ruleItemProvider = new RuleItemProvider(this);
		}

		return ruleItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Situation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SituationItemProvider situationItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Situation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSituationAdapter() {
		if (situationItemProvider == null) {
			situationItemProvider = new SituationItemProvider(this);
		}

		return situationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Binding} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BindingItemProvider bindingItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Binding}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBindingAdapter() {
		if (bindingItemProvider == null) {
			bindingItemProvider = new BindingItemProvider(this);
		}

		return bindingItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Relationship} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelationshipItemProvider relationshipItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Relationship}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRelationshipAdapter() {
		if (relationshipItemProvider == null) {
			relationshipItemProvider = new RelationshipItemProvider(this);
		}

		return relationshipItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.MaterialAssociation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MaterialAssociationItemProvider materialAssociationItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.MaterialAssociation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMaterialAssociationAdapter() {
		if (materialAssociationItemProvider == null) {
			materialAssociationItemProvider = new MaterialAssociationItemProvider(this);
		}

		return materialAssociationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.Parameter} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ParameterItemProvider parameterItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.Parameter}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createParameterAdapter() {
		if (parameterItemProvider == null) {
			parameterItemProvider = new ParameterItemProvider(this);
		}

		return parameterItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.SubstanceVariable} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SubstanceVariableItemProvider substanceVariableItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.SubstanceVariable}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSubstanceVariableAdapter() {
		if (substanceVariableItemProvider == null) {
			substanceVariableItemProvider = new SubstanceVariableItemProvider(this);
		}

		return substanceVariableItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.MomentVariable} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MomentVariableItemProvider momentVariableItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.MomentVariable}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMomentVariableAdapter() {
		if (momentVariableItemProvider == null) {
			momentVariableItemProvider = new MomentVariableItemProvider(this);
		}

		return momentVariableItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.QualityVariable} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityVariableItemProvider qualityVariableItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.QualityVariable}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createQualityVariableAdapter() {
		if (qualityVariableItemProvider == null) {
			qualityVariableItemProvider = new QualityVariableItemProvider(this);
		}

		return qualityVariableItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.QualityRelation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityRelationItemProvider qualityRelationItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.QualityRelation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createQualityRelationAdapter() {
		if (qualityRelationItemProvider == null) {
			qualityRelationItemProvider = new QualityRelationItemProvider(this);
		}

		return qualityRelationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link Alloy.QualityBinding} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityBindingItemProvider qualityBindingItemProvider;

	/**
	 * This creates an adapter for a {@link Alloy.QualityBinding}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createQualityBindingAdapter() {
		if (qualityBindingItemProvider == null) {
			qualityBindingItemProvider = new QualityBindingItemProvider(this);
		}

		return qualityBindingItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (specificationItemProvider != null) specificationItemProvider.dispose();
		if (universalItemProvider != null) universalItemProvider.dispose();
		if (rulesetItemProvider != null) rulesetItemProvider.dispose();
		if (kindRulesetItemProvider != null) kindRulesetItemProvider.dispose();
		if (subKindRulesetItemProvider != null) subKindRulesetItemProvider.dispose();
		if (relatorRulesetItemProvider != null) relatorRulesetItemProvider.dispose();
		if (phasePartitionRulesetItemProvider != null) phasePartitionRulesetItemProvider.dispose();
		if (modeRulesetItemProvider != null) modeRulesetItemProvider.dispose();
		if (qualityRulesetItemProvider != null) qualityRulesetItemProvider.dispose();
		if (ruleItemProvider != null) ruleItemProvider.dispose();
		if (situationItemProvider != null) situationItemProvider.dispose();
		if (bindingItemProvider != null) bindingItemProvider.dispose();
		if (relationshipItemProvider != null) relationshipItemProvider.dispose();
		if (materialAssociationItemProvider != null) materialAssociationItemProvider.dispose();
		if (parameterItemProvider != null) parameterItemProvider.dispose();
		if (substanceVariableItemProvider != null) substanceVariableItemProvider.dispose();
		if (momentVariableItemProvider != null) momentVariableItemProvider.dispose();
		if (qualityVariableItemProvider != null) qualityVariableItemProvider.dispose();
		if (qualityRelationItemProvider != null) qualityRelationItemProvider.dispose();
		if (qualityBindingItemProvider != null) qualityBindingItemProvider.dispose();
	}

}
